package com.ruoyi.order.controller;

import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.order.domain.StatisticsVo;
import com.ruoyi.order.domain.TbOrder;
import com.ruoyi.order.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Author: 少康
 * @Date: 2023/05/05/19:31
 */
@RestController
@RequestMapping("/statistics")
public class StatisticsController {
    @Autowired
    private StatisticsService statisticsService;

    @PostMapping("/statisticsnum")
    public R selectFoodNum(@RequestBody Map map){
        String str = (String) map.get("statisticstype");
        int statisticstype = Integer.parseInt(str);
        List<StatisticsVo> statisticsVos =new ArrayList<>();
        switch (statisticstype){
            case 1:statisticsVos=statisticsService.selectOrderNum(map);break;
            case 2:statisticsVos=statisticsService.selectOrderMoney(map);break;
            case 3:statisticsVos=statisticsService.selectUserNum(map);break;
            case 4:statisticsVos=statisticsService.selectdishes(map);break;
        }
        if (statisticsVos.size()>0){
            return R.ok(statisticsVos);
        }
        return R.fail("没有数据");
    }

}
